<?php
if (!isset($_SESSION))
    session_start();

/* 
 * We need to unset the post contents that we carry over secretly so that the
 * functions that verify the user inserted password and username are correct
 * function correctly
 */

if(!empty($_SESSION['currentPage'])){
    $postcontents = $_POST;
    $postVars = array(
      0 => "supplierType",
      1 => "roomRateKey",
      2 => "roomRateCode",
      3 => "roomTypeCode",
      4 => "hotelImage",
      5 => "hotelName",
      6 => "roomDescription",
      7 => "total",
      8 => "averageRate",
      9 => "hotelId",
     10 => "currentPage",
     11 => "accountCreation",
     12 => "roomtotal",
     13 => "nightlyRateTotal",
     14 => "surchargeTotal",
     15 => "currencyCode",
    );

    /* Actually does the unsetting unless the account has already been created*/
    if(isset($_POST['accountCreation'])){
        for ($i = 0; $i < count($postVars); $i++) {
            unset($_POST[$postVars[$i]]);
        }
    }
}
require_once("createclass.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <?php
    require('../../Smarty/libs/Smarty.class.php');

    $smarty = new Smarty;

    $user = ""; $email = "";
    if(isset($_POST["user"])) $user = $_POST["user"];
    if(isset($_POST["email"])) $email = $_POST["email"];
    $smarty->assign("user", $user);    
    $smarty->assign("email", $email);    
    $smarty->assign("error", $create->error);

    $smarty->setTemplateDir('./smarty/templates/');
    $smarty->setCompileDir('./smarty/templates_c/');
    $smarty->setConfigDir('./smarty/configs/');
    $smarty->setCacheDir('./smarty/cache/');
    
    if (empty($_SESSION['logged_bool'])) {
            $_SESSION['logged_bool'] = false;
        }
        $status = $_SESSION['logged_bool'];

        $smarty->assign("logged", $status);
        
    if(empty($_SESSION['currentPage'])){
        $smarty->assign('userReferred', FALSE);
    }
    else {
        
        $smarty->assign('currentPage',      $postcontents['currentPage']);
        $smarty->assign('hotelID',          $postcontents['hotelId']);
        $smarty->assign('supplierType',     $postcontents['supplierType']);
        $smarty->assign('roomRateKey',      $postcontents['roomRateKey']);
        $smarty->assign('roomRateCode',     $postcontents['roomRateCode']);
        $smarty->assign('roomTypeCode',     $postcontents['roomTypeCode']);
        $smarty->assign('hotelImage',       $postcontents['hotelImage']);
        $smarty->assign('hotelName',        $postcontents['hotelName']);
        $smarty->assign('roomDescription',  $postcontents['roomDescription']);
        $smarty->assign('total',            $postcontents['total']);
        $smarty->assign('averageRate',      $postcontents['averageRate']);
        $smarty->assign('roomtotal',        $postcontents['roomtotal']);
        $smarty->assign('nightlyRateTotal', $postcontents['nightlyRateTotal']);
        $smarty->assign('surchargeTotal',   $postcontents['surchargeTotal']);
        $smarty->assign('currencyCode',     $postcontents['currencyCode']);
        $smarty->assign('userReferred', TRUE);
    }
        
    $smarty->display('preHeader.tpl');
    echo '<body>';

    $smarty->display('header.tpl');
    $smarty->display('createAccount.tpl');
    $smarty->display('flashyBox.tpl');
    $smarty->display('footer.tpl');

    echo '</body>';
    ?>
</html>
